package com.taojiazheng.daoImpl.user;

import com.taojiazheng.dao.user.UserDao;
import com.taojiazheng.entity.Job;
import com.taojiazheng.entity.User;
import com.taojiazheng.entity.Userinfo;
import com.taojiazheng.mapper.UserMapper;
import com.taojiazheng.mapper.UserinfoMapper;
import com.taojiazheng.so.user.UserSo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * @author 赵成林
 * @date 2017/11/22 20:16
 */
@Repository
public class UserDaoImpl implements UserDao {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserinfoMapper userinfoMapper;

    public User getUserByToken(String token) {
        //return null;
        User user=userMapper.getUserByToken(token);
        return user;
    }

    public int insertUser(UserSo userSo) {
        int result = userMapper.insert(userSo);
        return result;
    }

    public User getUserByPhone(String phone) {
        User user = userMapper.getUserByPhone(phone);
        return user;
    }

    public User getUserByName(String name) {
        //return null;
        User user = userMapper.getUserByName(name);
        return user;
    }

    public int updateToken(UserSo userSo) {
        return userMapper.updateByPrimaryKeySelective(userSo);
    }

    public int createUserInfo(Userinfo userinfo) {
        return userinfoMapper.insert(userinfo);
    }
}
